home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 13 / 013.d81 / pps #31 < prev    next >
Encoding:
Text File  |  1985-01-01  |  3.2 KB  |  190 lines

  1.  
  2.   PEEKs, POKEs, and SYSes -- Part 31
  3.  
  4.           by Alan Gardner
  5.  
  6.  
  7.  
  8.  The next portion of ROUTINES V4 is a
  9.  
  10. routine called LINPUT.  LINPUT is
  11.  
  12. used to input up to 80 characters from
  13.  
  14. any input device.  This routine
  15.  
  16. allows use of such things as commas
  17.  
  18. and colons without getting an ?EXTRA
  19.  
  20. IGNORED error.  LINPUT inputs
  21.  
  22. characters until a carriage return
  23.  
  24. [CHR$(13)] has been found.
  25.  
  26. In using LINPUT, the file to access
  27.  
  28. must be OPENed prior to using the
  29.  
  30. routine.  For example, let's say we
  31.  
  32. wanted to read a SEQuential file
  33.  
  34. called TEXTSTUFF.  To use LINPUT, we
  35.  
  36. must use a few KERNAL routines to
  37.  
  38. help.  These are CHKIN and CLRCHN.
  39.  
  40. To use LINPUT in our example, you
  41.  
  42. could do the following:
  43.  
  44. 5  IFX=0THENX=1:LOAD"ROUTINES V4",8,1
  45. 6  :
  46. 10 OPEN 2,8,2,"TEXTSTUFF"
  47. 20 POKE 781,2 : SYS 65478 :REM _CHKIN
  48. 30 SYS 52016,A$           :REM _LINPUT
  49. 40 B$=MID$(A$,1)
  50. 50 PRINT B$ : IF ST=0THEN 30
  51. 60 SYS 65484              :REM _CLRCHN
  52. 70 CLOSE 2
  53.  
  54.  
  55.  The CHKIN routine used in line 20
  56.  
  57. is to OPEN channel two for input.
  58.  
  59. The number in the 'POKE 781,' must
  60.  
  61. be the first number in the OPEN
  62.  
  63. statement.  For example:
  64.  
  65.  
  66.  OPEN STATEMENT        POKE STATEMENT
  67.  {CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}{CBM-T}
  68.  
  69. OPEN 3,8,4,"name"        POKE 781,3
  70. OPEN 4,8,4,"name"        POKE 781,4
  71. OPEN 6,8,3,"name"        POKE 781,6
  72.  
  73.  
  74. Line 30 is the actual SYS to LINPUT.
  75.  
  76. Because LINPUT puts our string (A$) at
  77.  
  78. a different memory location than
  79.  
  80. BASIC does, we must make a
  81.  
  82. reassignment of the string.  This is
  83.  
  84. done in line 40.  After line 40, the
  85.  
  86. actual input from TEXTSTUFF is
  87.  
  88. contained in B$.  Line 50 prints our
  89.  
  90. string (B$) and then tests to see
  91.  
  92. if end-of-file has been reached.  If
  93.  
  94. end-of-file has been reached then we
  95.  
  96. fall through to lines 60 and 70.  Line
  97.  
  98. 60 clears all of the input/output
  99.  
  100. channels and line 70 actually closes
  101.  
  102. our file. If end-of-file has not been
  103.  
  104. reached, then we return to line 30 to
  105.  
  106. get some more text.
  107.  
  108.  
  109. ** NOTE **
  110.  
  111.    Do NOT attempt to input a string
  112.    that is more than 80 characters
  113.    long.  It will crash the system!!!
  114.  
  115.  
  116.  
  117.   The next portion of ROUTINES V4 is
  118.  
  119. reserved for COLORLISTER.  COLORLISTER
  120.  
  121. is a small routine which patches
  122.  
  123. itself into the LIST routine.
  124.  
  125. COLORLISTER puts an end to boring
  126.  
  127. single colored listings.
  128.  
  129.  To activate COLORLIST, all you need
  130.  
  131. is SYS 52080. To change the default
  132.  
  133. colors of your listing, change the
  134.  
  135. text color and/or background color.
  136.  
  137. Text color is changed by pressing the
  138.  
  139. CTRL or Commodore key along with a
  140.  
  141. key 1-8.  Background color is changed
  142.  
  143. with a POKE 53281,xx (xx should range
  144.  
  145. between 0 and 15).  After changing
  146.  
  147. your colors, all you need to do is
  148.  
  149. a SYS 52102.
  150.  
  151.  
  152.  The last part of ROUTINES V4 is known
  153.  
  154. as USR(PEEK).  If you are familiar
  155.  
  156. with the layout of the C-64, then you
  157.  
  158. know that in some places there is
  159.  
  160. RAM hidden under ROM.  We can POKE
  161.  
  162. things into this RAM easily enough,
  163.  
  164. but PEEKing from this RAM is nearly
  165.  
  166. impossible (without USR(PEEK) that
  167.  
  168. is).  USR(PEEK) 'looks' under the
  169.  
  170. ROM into the RAM to get its values.
  171.  
  172. For example:
  173.  
  174.  
  175.   PRINT PEEK(58909) will yield 48
  176.  
  177. while
  178.  
  179.   PRINT USR(58909)  will yield 247
  180.  
  181.  
  182. There is no SYS to turn USR(PEEK) on
  183.  
  184. and off, rather there is one SYS to
  185.  
  186. activate it.  This SYS is SYS 52176.
  187.  
  188.  
  189. =========< end of article >===========
  190.